home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / Mesa-3.0 / MKLIB.AIX < prev    next >
Encoding:
Korn shell script  |  1997-12-06  |  3.7 KB  |  158 lines

  1. #!/bin/ksh
  2.  
  3. # Make an AIX shared library (tricky!!!)
  4. # Based on a script from Athanasios G. Gaitatzes (gaitat@vnet.ibm.com)
  5. # Improved by Greg Thompson <gregt@visix.com> -gt
  6.  
  7. #--identification------------------------------------------------------
  8.  
  9. # $Id: mklib.aix,v 1.4 1997/12/06 15:16:05 brianp Exp $
  10.  
  11. # $Log: mklib.aix,v $
  12. # Revision 1.4  1997/12/06 15:16:05  brianp
  13. # added some missing system libs (Charles K. Hines)
  14. #
  15. # Revision 1.3  1997/10/21 23:32:31  brianp
  16. # now takes major and minor version arguments
  17. #
  18.  
  19. #--common--------------------------------------------------------------
  20.  
  21. # Usage:  mklib libname major minor file.o ...
  22. #
  23. # First argument is name of output library (LIBRARY)
  24. # Second arg is major version number (MAJOR)
  25. # Third arg is minor version number (MINOR)
  26. # Rest of arguments are object files (OBJECTS)
  27.  
  28. LIBRARY=$1
  29. shift 1
  30.  
  31. MAJOR=$1
  32. shift 1
  33.  
  34. MINOR=$1
  35. shift 1
  36.  
  37. OBJECTS=$*
  38.  
  39. #--platform------------------------------------------------------------
  40.  
  41. # BASENAME = LIBRARY without .a suffix
  42. BASENAME=`echo ${LIBRARY} | sed "s/\.a//g"`
  43.  
  44. # Name of exports file
  45. EXPFILE=${BASENAME}.exp
  46.  
  47. # Name of temporary shared lib file
  48. OFILE=shr.o
  49. ####OFILE=${BASENAME}.o
  50.  
  51.  
  52. # Remove any old files from previous make
  53. rm -f ${LIBRARY} ${EXPFILE} ${OFILE}
  54.  
  55. # Pick a way to use nm -gt
  56. NM=${NM-/bin/nm -eC}
  57.  
  58. # Determine which version of AIX this is
  59. AIXVERSION=`uname -v`
  60.  
  61. # Pick a way to tell the linker there's no entrypoint -gt
  62. case ${AIXVERSION}
  63. {
  64.     3*)
  65.         ENTRY='-e _nostart'
  66.         ;;
  67.     4*)
  68.         ENTRY=-bnoentry
  69.         ;;
  70.     *)
  71.         echo "Error in mklib.aix!"
  72.         exit 1
  73.         ;;
  74. }
  75.  
  76.  
  77. # Other libraries which we may be dependent on.  Since we make the libraries
  78. # in the order libMesaGL.a, libMesaGLU.a, libMesatk.a, libMesaaux.a each
  79. # just depends on its predecessor.
  80. # modified to make otherlibs in the form of -lfoo -gt
  81. OTHERLIBS=`ls ../lib/*.a | sed "s/..\/lib\/lib/-l/g" | sed "s/\.a//g"`
  82.  
  83. ##echo OTHERLIBS are ${OTHERLIBS}
  84.  
  85.  
  86. # Make exports (.exp) file header
  87. echo "#! ${LIBRARY}" > ${EXPFILE}
  88.  
  89. # Append list of exported symbols to exports file -gt
  90. case ${AIXVERSION}
  91. {
  92.     3*)
  93.     ${NM} ${OBJECTS} | awk -F'|' '{
  94.         if ($3 != "extern" || substr($7,1,1) == " ") continue
  95.         sub ("  *", "", $1); sub ("  *", "", $7)
  96.         if ( (($7 == ".text") || ($7 == ".data") || ($7 == ".bss"))  \
  97.             && ( substr($1,1,1) != ".")) {
  98.         if (substr ($1, 1, 7) != "__sinit" &&
  99.             substr ($1, 1, 7) != "__sterm") {
  100.             if (substr ($1, 1, 5) == "__tf1")
  101.             print (substr ($1, 7))
  102.             else if (substr ($1, 1, 5) == "__tf9")
  103.             print (substr ($1, 15))
  104.             else
  105.             print $1
  106.         }
  107.         }
  108.     }' | sort -u >> ${EXPFILE}
  109.     ;;
  110.  
  111.     4*)
  112.     ${NM} ${OBJECTS} | awk '{
  113.         if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
  114.             && ( substr($1,1,1) != ".")) {
  115.         if (substr ($1, 1, 7) != "__sinit" &&
  116.             substr ($1, 1, 7) != "__sterm") {
  117.             if (substr ($1, 1, 5) == "__tf1")
  118.             print (substr ($1, 7))
  119.             else if (substr ($1, 1, 5) == "__tf9")
  120.             print (substr ($1, 15))
  121.             else
  122.             print $1
  123.         }
  124.         }
  125.     }' | sort -u >> ${EXPFILE}
  126.     ;;
  127. }
  128.  
  129.  
  130. # This next line is a hack to allow full compatibility with IBM's OpenGL
  131. # libraries.  IBM mistakenly exports glLoadIdentity from the libGLU.a
  132. # library.  We have to do the same thing.  Problem reported by Yemi Adesanya
  133. # (adesanya@afsmail.cern.ch) and Patrick Brown (pbrown@austin.ibm.com)
  134. if [ "${BASENAME}" = libMesaGLU ] ; then
  135.     echo "glLoadIdentity" >> ${EXPFILE}
  136. fi
  137.  
  138.  
  139. # Make the shared lib file
  140. cc -o ${OFILE} ${OBJECTS} -L../lib ${OTHERLIBS} -lX11 -lXext -lXmu -lXi -lm -lc -bE:${EXPFILE} -bM:SRE ${ENTRY}
  141.  
  142.  
  143. # Make the .a file
  144. ar ruv ${LIBRARY} ${OFILE}
  145.  
  146. # Put exports file in Mesa lib directory
  147. mv ${EXPFILE} ../lib
  148.  
  149. # Remove OFILE
  150. rm -f ${OFILE}
  151.  
  152.  
  153. #NOTES
  154. # AIX 4.x /usr/bin/nm -B patch from ssclift@mach.me.queensu.ca (Simon Clift)
  155. # Robustified symbol extraction for AIX 3 and 4
  156. #   Greg Thompson <gregt@visix.com>
  157.  
  158.